package com.hs.mod_archive.view

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.widget.EditText
import android.widget.LinearLayout
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import com.hs.mod_archive.R

class MyListView : ConstraintLayout {
    lateinit var mBtFirstPage: View
    lateinit var mViewList: LinearLayout

    lateinit var mBtToPreviousPage: View

    lateinit var mBtToNextPage: View

    lateinit var mEtJumpToValue: EditText

    lateinit var mBtJumpTo: View

    lateinit var mTvTotalItem: TextView

    lateinit var mBtLastPage: View

    constructor(context: Context) : super(context) {
        this.init(null, 0, 0)
    }

    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
        this.init(attrs, 0, 0)
    }

    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context, attrs, defStyleAttr
    ) {
        this.init(attrs, defStyleAttr, 0)
    }

    constructor(
        context: Context, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int
    ) : super(context, attrs, defStyleAttr, defStyleRes) {
        this.init(attrs, defStyleAttr, defStyleRes)
    }

    private fun init(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) {
        val context = this.context
        //mBinding = LayoutTabTitleBarBinding.inflate(LayoutInflater.from(context));
        LayoutInflater.from(context).inflate(R.layout.view_list_view, this, true)
        //  addView(mBinding.getRoot());
        val resources = resources

        val ta = context.obtainStyledAttributes(attrs, R.styleable.MyListView)
        try {
            val defaultPaddingBottom = resources.getDimensionPixelSize(R.dimen.dp_40)
            val paddingBottom = ta.getDimensionPixelSize(
                R.styleable.MyListView_foot_padding_bottom, defaultPaddingBottom
            )
            setPadding(0, 0, 0, paddingBottom)
        } finally {
            ta.recycle()
        }
        mViewList = findViewById(R.id.view_list)
        mBtFirstPage = findViewById(R.id.bt_first_page)
        mBtToPreviousPage = findViewById(R.id.bt_previous_page)
        mBtToNextPage = findViewById(R.id.bt_next_page)
        mEtJumpToValue = findViewById(R.id.et_jump_to_value)
        mBtJumpTo = findViewById(R.id.bt_jump_to)
        mTvTotalItem = findViewById(R.id.tv_total_item)
        mBtLastPage = findViewById(R.id.bt_last_page)
    }
}
